import "nprogress/nprogress.css";
import {done,start} from 'nprogress';
import getPublicPath from './buildPath';


function asyncGetComponent(pageCompResolver){ //异步组件获取封装，传函数是为了capture错误
  return async ()=>{
    start()
    const comp = await pageCompResolver();
    done()
    return comp;
  }
}

const publicPath  = getPublicPath();


export default [{
    path: publicPath+'/',
    name: "Home",
    component: asyncGetComponent(() => import(/* webpackChunkName: "Home" */ "@/views/Home")),
    meta:{
      title:'首页'
    }
  },
  {
    path: publicPath+'/article',
    name: "Blog",
    component: asyncGetComponent(() => import(/* webpackChunkName: "Blog" */ "@/views/Blog")),
    meta:{
      title:'文章'
    }
  },
  {
    path: publicPath+'/article/cate/:categoryId',
    name: "CategoryBlog",
    component: asyncGetComponent(() => import(/* webpackChunkName: "Blog" */ "@/views/Blog")),
    meta:{
      title:'文章'
    }
  },
  {
    path: publicPath+'/article/detail/:id',
    name: "Detail",
    component: asyncGetComponent(() => import(/* webpackChunkName: "Detail" */ "@/views/Blog/Detail")),
    meta:{
      title:'文章详情'
    }
  },
  {
    path: publicPath+'/about',
    name: "About",
    component: asyncGetComponent(() => import(/* webpackChunkName: "About" */ "@/views/About")),
    meta:{
      title:'关于我'
    }
  },
  {
    path: publicPath+'/project',
    name: "Project",
    component:asyncGetComponent( () => import(/* webpackChunkName: "Project" */ "@/views/Project")),
    meta:{
      title:'项目&效果'
    }
  },
  {
    path: publicPath+'/message',
    name: "Message",
    component: asyncGetComponent(() => import(/* webpackChunkName: "Message" */ "@/views/Message")),
    meta:{
      auth:true,
      title:'留言板'
    }
  },
  {
    name:'NotFound',
    path:'*',
    component: asyncGetComponent(() => import(/* webpackChunkName: "Message" */ "@/views/NotFound")),
  }
]